/******************************************************************
 * created by deming.su on 2020-07-28 for mongodb connection
 ******************************************************************/

/** 引入mongoose */
const mongo = require('mongoose');

/** 引入连接地址 */
const {DATABASE_PATH} = require('../config');

/** 连接到指定数据库 */
mongo.connect(DATABASE_PATH);

/** 连接成功后的日志 */
const {logs} = require('../util');
mongo.connection.on('connected', () => {
    logs('mongodb connected');
});

/** 连接错误日志 */
mongo.connection.on('error', (e) => {
    logs('mongodb connect error', e);
});

/** 导出mongodb对象 */
module.exports = mongo;